package com.bjpowernode.service;

import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Service;


@Service
public class MyService {

    /**
     * spring的线程池
     */
    //@Autowired
    private ThreadPoolTaskExecutor applicationTaskExecutor;

    public void test() {
        System.out.println("test start......");
        applicationTaskExecutor.execute(() -> System.out.println("这是一个异步线程"));
        System.out.println("test end......");
    }

    @Async
    public void test2() {
        System.out.println("异步test......");
    }
}
